<?php

namespace app\admin\business;
use app\common\model\TradeChild;

class tradeBus {
    public $tradeMode = null;
    public $tradeChildMode = null;
    public function __construct()
    {
        $this->tradeMode = new \app\common\model\Trade;
        $this->tradeChildMode = new TradeChild();
    }
    //put your code here
    public function addTradeBus($data){
        $res = $this->tradeMode->addTrade($data);
        return $res;
    }
     public function getTradeList(){
        $result = $this->tradeMode->getTradeList();
        if(empty($result)){
            throw new \think\Exception('未查询到数据');
        }
        return $result;
    }
    public function getTradeById($where){
        $result = $this->tradeMode->getTradeById($where);
        if(empty($result)){
            throw new \think\Exception('未查询到数据');
        }
        return $result;
    }
    public function updateTrade($id,$data){
        $res = $this->tradeMode->updateTrade($id,$data);
        if(empty($res)){
            throw new \think\Exception('更新失败，数据未更改或者数据库连接异常');
        }
        return $res;
    }
//------------------------------------------------------------------------------------------

    public function getNewsList($current_page,$num){
        $result = $this->tradeChildMode->getListPage($current_page,$num);
        if(empty($result)){
            throw new \think\Exception('未查询到数据');
        }
        return $result;
    }
    public function addTradeChild($data){
        $res = $this->tradeChildMode->addTradeChild($data);
        return $res;
    }
    public function getTradeChildByIdBus($where){
        $result = $this->tradeChildMode->getTradeChildById($where);
        if(empty($result)){
            throw new \think\Exception('未查询到数据');
        }
        return $result;
    }
    public function updateTradeChild($id,$data){
        $res = $this->tradeChildMode->updateTradeChild($id,$data);
        if(empty($res)){
            throw new \think\Exception('更新失败，数据未更改或者数据库连接异常');
        }
        return $res;
    }
    public function removeTradeChild($id){
        $result = $this->tradeChildMode->removeTradeChild($id);
        if(empty($result)){
            throw new \think\Exception("未查到删除的信息或者改信息已经删除");
        }
        return $result;
    }

}
